* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    width: 100vw;
    background: #f5f5f5;
    overflow: hidden; /* Prevent scrollbars on body */
}

.container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.left-panel {
    flex: 1 1 auto; /* Allow shrinking when space is limited */
    min-width: 300px; /* Minimum width to maintain usability */
    background: white;
    border-right: 2px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.spreadjs-header {
    padding: 15px;
    background: #2c3e50;
    color: white;
    text-align: center;
    font-weight: bold;
}

.spreadjs-container {
    flex: 1;
    padding: 10px;
    overflow: hidden; /* Prevent content overflow */
}

.right-panel {
    width: 400px;
    min-width: 350px; /* Minimum width for chat panel */
    max-width: 450px; /* Maximum width to prevent taking too much space */
    flex-shrink: 0; /* Prevent shrinking - prioritize left panel compression */
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 15px;
    background: #34495e;
    color: white;
    text-align: center;
    font-weight: bold;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    height: 0; /* Force flex item to respect flex constraints */
    display: flex;
    flex-direction: column;
}

.message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 8px;
}

.user-message {
    background: #e3f2fd;
    margin-left: 20px;
}

.agent-message {
    background: #f3e5f5;
    margin-right: 20px;
}

.agent-message.streaming .content {
    animation: typing 0.5s ease-in-out;
}

@keyframes typing {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

.system-message {
    background: #e8f5e8;
    margin: 0 10px;
    text-align: center;
    border: 1px solid #4caf50;
    color: #2e7d32;
}

.agent-step {
    background: #fff3e0;
    margin: 10px 0;
    border-left: 4px solid #ff9800;
}

.step-header {
    cursor: pointer;
    font-weight: bold;
    padding: 8px 12px;
    background: #fff8e1;
}

.step-content {
    padding: 12px;
    border-top: 1px solid #ffe0b2;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: #fafafa;
    display: none;
}

.step-content.expanded {
    display: block;
}

.input-area {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
}

.input-container {
    display: flex;
    gap: 10px;
}

#userInput {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

#sendButton {
    padding: 10px 20px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#sendButton:hover {
    background: #1976d2;
}

#sendButton:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.status {
    padding: 10px;
    text-align: center;
    background: #e8f5e8;
    color: #2e7d32;
    font-size: 12px;
}

.status.connecting {
    background: #fff3e0;
    color: #f57c00;
}

.status.error {
    background: #ffebee;
    color: #c62828;
}

.tool-call {
    background: #e8f5e8;
    border: 1px solid #4caf50;
    margin: 8px 0;
    border-radius: 4px;
}

.tool-name {
    font-weight: bold;
    color: #2e7d32;
}

.timestamp {
    color: #666;
    font-size: 11px;
    margin-top: 5px;
}

/* 新的工具显示样式 */
.tool-input {
    margin: 10px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #007bff;
}

.input-label {
    font-weight: bold;
    color: #495057;
    margin-bottom: 5px;
    font-size: 12px;
}

.input-content {
    background: white;
    padding: 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    border: 1px solid #dee2e6;
    word-wrap: break-word;
}

.code-block {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    border: 1px solid #dee2e6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.tool-status {
    color: #6c757d;
    font-style: italic;
    padding: 5px 8px;
    background: #e9ecef;
    border-radius: 3px;
    margin: 8px 0;
    font-size: 11px;
}

.tool-output {
    margin: 10px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #28a745;
}

.output-label {
    font-weight: bold;
    color: #495057;
    margin-bottom: 5px;
    font-size: 12px;
}

.result-content {
    background: white;
    padding: 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    border: 1px solid #dee2e6;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 8px;
}

.result-content.success {
    color: #155724;
    background: #d4edda;
    border-color: #c3e6cb;
}

.result-content.error {
    color: #721c24;
    background: #f8d7da;
    border-color: #f5c6cb;
}

.search-results {
    margin-top: 5px;
}

.search-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    margin-bottom: 8px;
    padding: 8px;
}

.search-title {
    font-weight: bold;
    color: #495057;
    margin-bottom: 3px;
    font-size: 11px;
}

.search-answer {
    color: #6c757d;
    font-size: 10px;
    line-height: 1.3;
}

.more-results {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    padding: 5px;
    font-size: 10px;
}

.agent-step.completed {
    border-left-color: #28a745;
}

.agent-step.completed .step-header {
    background: #d4edda;
    color: #155724;
}

/* 工具特定的颜色主题 */
.agent-step[id*="gcqa"] {
    border-left-color: #17a2b8;
}

.agent-step[id*="gcqa"] .step-header {
    background: #d1ecf1;
    color: #0c5460;
}

.agent-step[id*="execute"] {
    border-left-color: #ffc107;
}

.agent-step[id*="execute"] .step-header {
    background: #fff3cd;
    color: #856404;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .right-panel {
        width: 300px;
        min-width: 280px;
        max-width: 350px;
    }

    .left-panel {
        min-width: 250px;
    }
}

@media (max-width: 600px) {
    .container {
        flex-direction: column;
    }

    .left-panel {
        height: 60vh;
        min-width: auto;
        border-right: none;
        border-bottom: 2px solid #e0e0e0;
    }

    .right-panel {
        height: 40vh;
        width: 100%;
        min-width: auto;
        max-width: none;
    }

    .chat-messages {
        height: calc(40vh - 120px);
    }
}

/* Ensure SpreadJS content scales properly */
#ss {
    width: 100% !important;
    height: 100% !important;
    min-height: 200px;
}